/**
 * Copyright &copy; 2012-2016 <a href="https://git.oschina.net/zdw2016/webbase5">Webbase</a> All rights reserved.
 */
package com.foreveross.webbase.project.entity;

import org.hibernate.validator.constraints.Length;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.validation.constraints.NotNull;

import com.foreveross.webbase.common.persistence.DataEntity;
import com.foreveross.webbase.system.sys.entity.Role;
import com.google.common.collect.Lists;

/**
 * 项目管理Entity
 * @author yangwanli
 * @version 2017-03-14
 */
public class SysSpProject extends DataEntity<SysSpProject> {
	
	private static final long serialVersionUID = 1L;
	private String projectName;		// 项目名称
	private String descri;		// 项目描述
	private String mangerName;		// 项目经理
	private Date startTime;		// 开始时间
	private Date endTime;		// 结束时间
	private String softName;		// 服务器软件名称
	private String status;		// 状态
	private String serveltInformation;		// 服务器信息
	private List<String> typeIdList=Lists.newArrayList();//拥有的服务器列表
	
	public SysSpProject() {
		super();
	}

	public SysSpProject(String id){
		super(id);
	}

	@Length(min=1, max=255, message="项目名称长度必须介于 1 和 255 之间")
	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}
	
	@Length(min=0, max=255, message="项目描述长度必须介于 0 和 255 之间")
	public String getDescri() {
		return descri;
	}

	public void setDescri(String descri) {
		this.descri = descri;
	}
	
	@Length(min=0, max=255, message="项目经理长度必须介于 0 和 255 之间")
	public String getMangerName() {
		return mangerName;
	}

	public void setMangerName(String mangerName) {
		this.mangerName = mangerName;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="开始时间不能为空")
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="结束时间不能为空")
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	
	@Length(min=0, max=255, message="服务器软件名称长度必须介于 0 和 255 之间")
	public String getSoftName() {
		return softName;
	}

	public void setSoftName(String softName) {
		this.softName = softName;
	}
	
	@Length(min=0, max=10, message="状态长度必须介于 0 和 10 之间")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@Length(min=0, max=255, message="服务器信息长度必须介于 0 和 255 之间")
	public String getServeltInformation() {
		return serveltInformation;
	}

	public void setServeltInformation(String serveltInformation) {
		this.serveltInformation = serveltInformation;
	}
	
	@JsonIgnore
	public List<String> getTypeIdList() {
		List<String> typeIdList = Lists.newArrayList();
		
		String[] strs=this.softName.split(",");
		for (String str:strs) {
			typeIdList.add(str);
		}
		return typeIdList;
	}
	
//	public void setTypeIdList(List<String> typeIdList) {
//		typeIdList = Lists.newArrayList();
//		for (String typeId : typeIdList) {
//			Role role = new Role();
//			role.setId(typeId);
//			roleList.add(role);
//		}
//	}
}